<template>
	<view class="mainPage settime" :style="{'padding-top': `${$store.state.safeArea.top || 0}px`, 'padding-bottom': `${$store.state.safeArea.bottom || 0}px`}">
		<public-head :title="title"></public-head>
		<view class="box">
			<view class="box_1" v-for="(item,index) in times" :key="index">
				<view class="week">{{index==0?'周一':index==1?'周二':index==2?'周三':index==3?'周四':index==4?'周五':index==5?'周六':index==6?'周日':''}}</view>
				<view class="morning" :class="items.status==1?'active':''" v-for="(items,indexs) in times[index]" :key="indexs" @click.stop="dianji(items)">
					<view>{{indexs==0?'上午':'下午'}}</view>
					<view>{{items.s_time}}-{{items.e_time}}</view>
				</view>
			</view>
		</view>
		<!-- 按钮 -->
		<view class="but">
			<button class="but1 but2" @click="sttimes">保存</button>
		</view>
	</view>
</template>
<script>
var that
import publicHead from "@/components/publicHead/publicHead.vue"
export default {
	components: {
		publicHead
	},
	data() {
		return {
			title: "出诊时间设置",
			timezi: '',
			times2zi: '',
			timesstatus: '',
			times2status: '',
			times: [
				[
					{
						"status": 0,//0
						"s_time": "9:00",
						"e_time": "12:00"
					}, {
						"status": 0,//0
						"s_time": "14:00",
						"e_time": "18:00"
					}
				],
				[
					{
						"status": 0,//0
						"s_time": "9:00",
						"e_time": "12:00"
					}, {
						"status": 0,//0
						"s_time": "14:00",
						"e_time": "18:00"
					}
				],
				[
					{
						"status": 0,//0
						"s_time": "9:00",
						"e_time": "12:00"
					}, {
						"status": 0,//0
						"s_time": "14:00",
						"e_time": "18:00"
					}
				],
				[
					{
						"status": 0,//0
						"s_time": "9:00",
						"e_time": "12:00"
					}, {
						"status": 0,//0
						"s_time": "14:00",
						"e_time": "18:00"
					}
				],
				[
					{
						"status": 0,//0
						"s_time": "9:00",
						"e_time": "12:00"
					}, {
						"status": 0,//0
						"s_time": "14:00",
						"e_time": "18:00"
					}
				],
				[
					{
						"status": 0,//0
						"s_time": "9:00",
						"e_time": "12:00"
					}, {
						"status": 0,//0
						"s_time": "14:00",
						"e_time": "18:00"
					}
				],
				[
					{
						"status": 0,//0
						"s_time": "9:00",
						"e_time": "12:00"
					}, {
						"status": 0,//0
						"s_time": "14:00",
						"e_time": "18:00"
					}
				],
			],
		}
	},
	onLoad() {
		that = this
		that.information()
	},
	methods: {
		dianji(items) {
			items.status = !items.status
			if (items.status == false) {
				items.status = 0
			} else if (items.status == true) {
				items.status = 1
			}
			console.log('times', that.times,)
		},
		// 设置时间
		sttimes() {
			that.$postAjax1('YuYue_set_yuyue', {
				type: 5,//设置时间
				value: JSON.stringify(that.times)
			}, function (data) {
				uni.navigateBack({
				})
				console.log('设置成功')
			})
		},
		// 获取预约信息
		information() {
			that.$postAjax1('YuYue_get_yuyue_config', {
			}, function (data) {
				that.informations = data.data.data
				if (that.informations.time_data.length != 0) {
					that.times = that.informations.time_data
				}
				console.log(that.informations)
			})
		},
	}
}
</script>
<style scoped lang="scss">
.settime {
	background-color: #f4f4f4;
	height: 100vh;
	.box {
		background-color: #ffffff;
		padding-bottom: 30rpx;
		.box_1 {
			width: 100%;
			padding: 0rpx 40rpx;
			display: flex;
			align-items: center;
			.week {
				display: inline-block;
				width: 15%;
				font-size: 32rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #323232;
				line-height: 44rpx;
			}
			.morning {
				display: inline-block;
				text-align: center;
				width: 40%;
				border: 2rpx solid #dcdcdc;
				border-radius: 12rpx;
				margin: 12rpx 7rpx;
				padding: 8rpx 0;
				font-size: 30rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #909090;
				line-height: 42rpx;
			}
			.active {
				font-size: 30rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #ffffff;
				line-height: 42rpx;
				background: linear-gradient(270deg, #ffc347, #ff9331);
			}
			.afternoon {
				display: inline-block;
				text-align: center;
				width: 40%;
				border: 2rpx solid #dcdcdc;
				border-radius: 12rpx;
				margin: 12rpx 7rpx;
				padding: 8rpx 0;
				font-size: 30rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #909090;
				line-height: 42rpx;
			}
		}
	}
	.but {
		margin-top: 80rpx;
		.but1 {
			width: 630rpx;
			height: 92rpx;
			background: #c4c4c6;
			border-radius: 46rpx;
			font-size: 32rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #ffffff;
		}
		.but2 {
			background: #ff8f2b;
			box-shadow: 0px 6rpx 8rpx 0px rgba(255, 143, 43, 0.2);
		}
	}
}
</style>
